package com.hnas.eCard.service.impl;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.hnas.eCard.dao.EntityCardOrderDetailDao;
import com.hnas.eCard.orm.EntityCardOrderDetail;
import com.hnas.eCard.service.EntityCardOrderDetailService;
import com.hnas.eCard.service.dto.DTOEntityCardOrderDetail;

@Component("entityCardOrderDetailService")
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class EntityCardOrderDetailServiceImpl implements EntityCardOrderDetailService{

	@Autowired
	private EntityCardOrderDetailDao entityCardOrderDetailDao;

	@Override
	public EntityCardOrderDetail saveOrUpdate(DTOEntityCardOrderDetail dto) {
		return this.entityCardOrderDetailDao.saveOrUpdate(dto);
	}

	@Override
	public EntityCardOrderDetail findByOrderNo(String orderNo) {
		return this.entityCardOrderDetailDao.findByOrderNo(orderNo);
	}

	@Override
	public DTOEntityCardOrderDetail findDTOByOrderNo(String orderNo) {
		EntityCardOrderDetail detail = this.entityCardOrderDetailDao.findByOrderNo(orderNo);
		DTOEntityCardOrderDetail dto = new DTOEntityCardOrderDetail();
		BeanUtils.copyProperties(detail, dto);
		return dto;
	}

	@Override
	public boolean confirmConsume(String accId, String orderNo,String mrchId,String termNo,String dealDate) {
		return this.entityCardOrderDetailDao.confirmConsume(accId,orderNo,mrchId,termNo,dealDate);
	}
}
